package org.karelun.rabbit.rcp;

import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

	private IWorkbenchAction saveAction;
	
	private IWorkbenchAction undoAction;
	
	private IWorkbenchAction redoAction;
	
	private IWorkbenchAction deleteAction;
	
	private IWorkbenchAction copyAction;
	
	private IWorkbenchAction cutAction;
	
	private IWorkbenchAction pasteAction;
	
    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {
    	saveAction=ActionFactory.SAVE.create(window);
    	undoAction=ActionFactory.UNDO.create(window);
    	redoAction=ActionFactory.REDO.create(window);
    	copyAction=ActionFactory.COPY.create(window);
    	cutAction=ActionFactory.CUT.create(window);
    	pasteAction=ActionFactory.PASTE.create(window);
    	deleteAction=ActionFactory.DELETE.create(window);
    	
    	register(saveAction);
    	register(undoAction);
    	register(redoAction);
    	register(copyAction);
    	register(cutAction);
    	register(pasteAction);
    	register(deleteAction);
    }

    protected void fillMenuBar(IMenuManager menuBar) {
    	String fileMenuPath="org.karelun.rabbit.ui.file.menu";
    	IMenuManager fileMenuMgr = menuBar.findMenuUsingPath(fileMenuPath);
    	if(fileMenuMgr==null){
    		fileMenuMgr=new MenuManager("&File", fileMenuPath);
    		menuBar.add(fileMenuMgr);
    	}
    	fileMenuMgr.add(saveAction);
    	fileMenuMgr.add(undoAction);
    	fileMenuMgr.add(redoAction);
    	fileMenuMgr.add(new Separator());
    	fileMenuMgr.add(copyAction);
    	fileMenuMgr.add(cutAction);
    	fileMenuMgr.add(pasteAction);
    	fileMenuMgr.add(deleteAction);
    }
    
}
